🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / testing / src / commonMain / kotlin / org / meshtastic / core / testing / FakeRadioTransport.kt
Displaying Raw • Download
core/testing/src/commonMain/kotlin/org/meshtastic/core/testing/FakeRadioTransport.kt 41414f832f938b655c97bc07509bc140ea16e2a3 (41414f83) Text, 2.41 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.testing
Tff7b72import T7ee787kotlinx.atomicfu.locks.SynchronizedObject
Tff7b72import T7ee787kotlinx.atomicfu.locks.synchronized
Tff7b72import T7ee787org.meshtastic.core.repository.RadioTransport
T8b949e/** A test double for [RadioTransport] that tracks sent data. */
Tff7b72class T56d364FakeRadioTransport Tb4b4b4: Te6edf3RadioTransport Tb4b4b4{
Tff7b72private Tff7b72val Te6edf3lock Tff7b72= Te6edf3SynchronizedObjectTb4b4b4(Tb4b4b4)
Tff7b72private Tff7b72val Te6edf3mutableSentData Tff7b72= Te6edf3mutableListOfTff7b72<Te6edf3ByteArrayTff7b72>Tb4b4b4(Tb4b4b4)
Tff7b72val Te6edf3sentDataTb4b4b4: Te6edf3ListTff7b72<Te6edf3ByteArrayTff7b72>
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Te6edf3mutableSentDataTb4b4b4.Te6edf3map Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3copyOfTb4b4b4(Tb4b4b4) Tb4b4b4} Tb4b4b4}
T8b949e/** Clears the recorded payload history without changing transport lifecycle state. */
Tff7b72fun Td2a8ffclearSentDataTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Te6edf3mutableSentDataTb4b4b4.Te6edf3clearTb4b4b4(Tb4b4b4) Tb4b4b4}
Tb4b4b4}
T8b949e/** Clears the recorded heartbeat without changing transport lifecycle state. */
Tff7b72fun Td2a8ffclearKeepAliveTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Te6edf3keepAliveCalledState Tff7b72= Tff7b72false Tb4b4b4}
Tb4b4b4}
Tff7b72private Tff7b72var Te6edf3closeCalledState Tff7b72= Tff7b72false
Tff7b72val Te6edf3closeCalledTb4b4b4: Tffa657Boolean
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Te6edf3closeCalledState Tb4b4b4}
Tff7b72private Tff7b72var Te6edf3closeCountState Tff7b72= T79c0ff0
Tff7b72val Te6edf3closeCountTb4b4b4: Tffa657Int
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Te6edf3closeCountState Tb4b4b4}
Tff7b72private Tff7b72var Te6edf3keepAliveCalledState Tff7b72= Tff7b72false
Tff7b72val Te6edf3keepAliveCalledTb4b4b4: Tffa657Boolean
Tff7b72getTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Te6edf3keepAliveCalledState Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffhandleSendToRadioTb4b4b4(Te6edf3pTb4b4b4: Te6edf3ByteArrayTb4b4b4)Tb4b4b4: Tffa657Boolean Tff7b72= Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3closeCalledStateTb4b4b4) Tff7b72returnTf0883e@synchronized Tff7b72false
Te6edf3mutableSentDataTb4b4b4.Te6edf3addTb4b4b4(Te6edf3pTb4b4b4.Te6edf3copyOfTb4b4b4(Tb4b4b4)Tb4b4b4)
Tff7b72true
Tb4b4b4}
Tff7b72override Tff7b72fun Td2a8ffkeepAliveTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{ Tff7b72if Tb4b4b4(Tff7b72!Te6edf3closeCalledStateTb4b4b4) Te6edf3keepAliveCalledState Tff7b72= Tff7b72true Tb4b4b4}
Tb4b4b4}
Tff7b72override Tff7b72suspend Tff7b72fun Td2a8ffcloseTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3synchronizedTb4b4b4(Te6edf3lockTb4b4b4) Tb4b4b4{
Te6edf3closeCalledState Tff7b72= Tff7b72true
Te6edf3closeCountStateTff7b72+Tff7b72+
Tb4b4b4}
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.04s